from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
from testcases.api.login_test import TestCaseLogin


class TestCaseOrder(HttpRunner):
    config = Config("登录查询代理商").base_url("${read_config()}")

    teststeps = [
        Step(
            RunTestCase("步骤1-登录")
            .call(TestCaseLogin)
            .export("token", "Uid")  # 确保导出 token
        ),
        Step(
            RunRequest("步骤2-查询代理商")
            .post("/api/user/get")
            .with_headers(token="$token", Uid="${int_str($Uid)}", content_type="application/json; charset=utf-8")  # 正确传递 headers,Uid
            .with_json({
                "pageIndex": 1,
                "pageSize": 10,
                "sorts": "create_time desc",
                "pk_id": 13373,
                "username": "xiaogao",
                "dtype": "校园代理",
                "phone": "15985645488"
            })
            .validate()
            .assert_equal("status_code", 200)
        )
    ]
